package del2;

public class JobConsumer implements Runnable {
    PrintQueue queue;

    public JobConsumer(PrintQueue queue) {
    	this.queue = queue;
    }

    public void run() {
    	synchronized(queue){
    		while(true){
    			if(queue.size() < 1){
	    			try{
	    				queue.wait();
	    			}catch(InterruptedException iex){
	    				System.out.println("Interrupted!");
	    			}
	    		}
				System.out.println(queue.removeJob().toString());
	    	}
    	}
    }
}
